Base de interesse

Modelos gerais sem estratificação

# Modelo geral sem estratificacao
#m0 <- gamlss(nhosp ~ age_cat + cd_estado_civil + cod_local_domic_fam_eq + ah_paciente_sexo, data = data_model, family = "LG")




mod = "
nhosp ~ age_cat + cd_estado_civil + cod_local_domic_fam_eq + ah_paciente_sexo

"

model <- umxRAM(mod, data = data_model)
You have raw data, but no means model. I added
mxPath('one', to = manifestVars)
object 'threshMat' created to handle: 2 ordinal variables:'cd_estado_civil' and 'age_cat'
: 2 binary variables:'cod_local_domic_fam_eq' and 'ah_paciente_sexo'
2 trait(s) are binary: 'cod_local_domic_fam_eq' and 'ah_paciente_sexo'
For these, you you MUST fix the mean and variance of the latent traits driving each variable (usually 0 & 1 respectively) .
See ?umxThresholdMatrix
2 variables are ordinal (>2 levels). For these I will use Paras Mehta's 'fix first 2 thresholds' method.
It's ESSENTIAL that you leave the means and variances of the latent ordinal traits FREE!
See ?umxThresholdMatrix
Using deviation-based model: Thresholds will be in'threshMat' based on deviations in 'deviations_for_thresh'
Running m1 with 25 parameters
?umxSummary std=T|F', digits, report= 'html', filter= 'NS' & more
Running Saturated m1 with 21 parameters
Running Independence m1 with 11 parameters


Table: Parameter loadings for model 'm1'

|   |name                                               | Estimate|SE     |type          |
|:--|:--------------------------------------------------|--------:|:------|:-------------|
|7  |cd_estado_civil_with_cod_local_domic_fam_eq        |    -0.37|0.167  |Manifest Cov  |
|8  |age_cat_with_cd_estado_civil                       |     0.81|0.003  |Manifest Cov  |
|9  |ah_paciente_sexo_with_cd_estado_civil              |     0.03|       |Manifest Cov  |
|11 |age_cat_with_cod_local_domic_fam_eq                |     0.12|       |Manifest Cov  |
|12 |ah_paciente_sexo_with_cod_local_domic_fam_eq       |     0.12|       |Manifest Cov  |
|14 |age_cat_with_ah_paciente_sexo                      |     0.02|       |Manifest Cov  |
|1  |cd_estado_civil_to_nhosp                           |    -0.19|0.712  |Manifest path |
|2  |cod_local_domic_fam_eq_to_nhosp                    |    -0.01|0.338  |Manifest path |
|3  |age_cat_to_nhosp                                   |     0.15|0.616  |Manifest path |
|4  |ah_paciente_sexo_to_nhosp                          |    -0.36|       |Manifest path |
|16 |one_to_nhosp                                       |     1.38|       |Mean          |
|17 |one_to_cd_estado_civil                             |    -0.01|0.204  |Mean          |
|18 |one_to_cod_local_domic_fam_eq                      |     0.06|14.495 |Mean          |
|19 |one_to_age_cat                                     |     0.01|0.174  |Mean          |
|20 |one_to_ah_paciente_sexo                            |     0.07|       |Mean          |
|5  |nhosp_with_nhosp                                   |     0.79|0.187  |Residual      |
|6  |cd_estado_civil_with_cd_estado_civil               |     1.07|0.327  |Residual      |
|10 |cod_local_domic_fam_eq_with_cod_local_domic_fam_eq |     1.16|0.92   |Residual      |
|13 |age_cat_with_age_cat                               |     1.02|0.258  |Residual      |
|15 |ah_paciente_sexo_with_ah_paciente_sexo             |     0.87|       |Residual      |

Model Fit: χ²(-4) = -0.15, p = NaN; CFI = 0.859; TLI = 1; RMSEA = 0
Algebra'threshMat':


|     | cd_estado_civil| cod_local_domic_fam_eq| age_cat| ah_paciente_sexo|
|:----|---------------:|----------------------:|-------:|----------------:|
|th_1 |            0.74|                  -0.61|   -1.50|             0.93|
|th_2 |            2.07|                   0.01|   -0.75|             0.93|
|th_3 |            2.07|                   0.01|    0.22|             0.93|
|th_4 |            2.07|                   0.01|    0.22|             0.93|
model <- umxRun(model)
Running m1 with 25 parameters

Beginning initial fit attempt
Running m1 with 25 parameters

 Lowest minimum so far:  929.73876838364
 Not all eigenvalues of the Hessian are positive: 629.658894006603, 464.798620847284, 391.272445298598, 309.952947796108, 294.568312264148, 232.673059665588, 222.661473892884, 197.792068765122, 160.551340727726, 147.056752579727, 117.528349434755, 84.2210671819762, 59.860303177303, 49.1812818934163, 42.1476533561773, 23.4455296673855, 17.8266183009572, 9.78384298910371, 4.18428830054139, 2.02168299454644, 0.00206791227213378, -0.0000000328933989961287, -0.00102596446230338, -0.0174912041672792, -3.25454568681617

Beginning fit attempt 1 of at maximum 10 extra tries
Running m1 with 25 parameters

 Lowest minimum so far:  929.73876838364
 Not all eigenvalues of the Hessian are positive: 629.659086143908, 464.798633623116, 391.272507718333, 309.952942715333, 294.568314450257, 232.673061854883, 222.661473149053, 197.792066569279, 160.551356012228, 147.05676446057, 117.528357150734, 84.2210700468507, 59.8603123778832, 49.1812864340063, 42.1476560285754, 23.4455342327642, 17.8266241509476, 9.7838457734931, 4.18429050861562, 2.02168215710534, 0.00206914207461184, 0.0000000566792066553426, -0.00102617764180412, -0.0174899583228518, -3.25454734717118

Beginning fit attempt 2 of at maximum 10 extra tries
Running m1 with 25 parameters

 Lowest minimum so far:  929.738768383637
 Not all eigenvalues of the Hessian are positive: 629.659091045489, 464.798517754845, 391.272553229238, 309.952898115571, 294.568319390187, 232.673045899678, 222.661354007805, 197.792012988228, 160.551432047608, 147.056809283167, 117.528372931095, 84.221097313331, 59.8603312674892, 49.1813009438073, 42.1476673283644, 23.44554858553, 17.8266318614136, 9.78384808892065, 4.18429137415194, 2.0216834264588, 0.00207091390835064, 0.000000070586895403171, -0.00102558597406848, -0.01748842203669, -3.25454573768513

Beginning fit attempt 3 of at maximum 10 extra tries
Running m1 with 25 parameters

 Lowest minimum so far:  929.738768383635
 Not all eigenvalues of the Hessian are positive: 630.930652465769, 465.811908138829, 392.63739652634, 309.046269094937, 294.820523515753, 236.422179583057, 222.97331918269, 196.401294286568, 160.697599007432, 148.401634692814, 117.782268143448, 84.1833353100806, 60.5783703500721, 49.5371001154697, 42.9533679939809, 23.4502625088449, 17.8304717119048, 9.84091285112235, 4.2142860193577, 2.01850287434314, 0.00206606659978703, 0.0000000725574679482635, -0.00102251526290501, -0.0170359445176172, -3.3122137739745

Beginning fit attempt 4 of at maximum 10 extra tries
Running m1 with 25 parameters
 Not all eigenvalues of the Hessian are positive: 630.546391429988, 467.491024926452, 392.078663822946, 303.662452498117, 284.05602564853, 237.313918333011, 221.295855088792, 195.167163988522, 158.203714069754, 145.625775752854, 117.581698049672, 85.6646994669782, 63.1687967187074, 47.2277927450205, 40.8631216188932, 24.1049111789265, 17.4335227276433, 8.72840094777513, 4.17094599325093, 2.01351676910588, 0.00162292025442291, -0.0000000228384188946991, -0.00104613074409544, -0.0313921602054621, -3.37328766805476

Beginning fit attempt 5 of at maximum 10 extra tries
Running m1 with 25 parameters
 Not all eigenvalues of the Hessian are positive: 603.21773054621, 455.438039620996, 373.584056534791, 350.521890076832, 272.526648647723, 244.927405398536, 173.007042775464, 134.714860420588, 120.524974379439, 109.562981359024, 94.6361774010081, 70.7441266955954, 34.6470979238733, 31.5398302802102, 24.5755472649016, 17.4968562635343, 16.580427897885, 8.51918986243827, 2.71140659095461, 2.09978605709511, 0.00107520547506687, 0.0000000685910539683451, -0.000000674542409724484, -0.00127251810324531, -1.91925145640958

Beginning fit attempt 6 of at maximum 10 extra tries
Running m1 with 25 parameters
 Not all eigenvalues of the Hessian are positive: 634.124248009305, 468.960539118181, 399.938902007994, 344.666506744974, 252.565618846741, 244.800465936243, 183.181586445544, 145.002433853482, 141.061033575116, 118.771741962639, 94.7425441804264, 84.3720153995333, 51.4994553596946, 34.9622523506275, 29.9508909557827, 24.3022589793649, 17.5252680061957, 9.30387097634736, 4.27822849359681, 2.00902177452194, 0.000501967555788047, 0.0000000695763433820656, -0.000705180010469156, -0.0201176280243252, -3.51119666419844

Beginning fit attempt 7 of at maximum 10 extra tries
Running m1 with 25 parameters
 Not all eigenvalues of the Hessian are positive: 601.980008845455, 461.539090993872, 396.782300605371, 358.665623771994, 299.362007212527, 272.648686336236, 220.287811964083, 158.045288590408, 126.992183849689, 119.849381421869, 93.7814768952193, 67.5760120153385, 52.6297933352555, 27.9934994273275, 23.3779318186082, 21.9233202006764, 17.4983464384923, 8.43125341886885, 2.6495377069567, 2.09150586036243, 0.00224704453020314, -0.0000000506032742618829, -0.000000458037526527137, -0.00170621678081691, -1.74888780884481

Beginning fit attempt 8 of at maximum 10 extra tries
Running m1 with 25 parameters

 Fit attempt worse than current best:  1051.63395536025 vs 929.738768383635

Beginning fit attempt 9 of at maximum 10 extra tries
Running m1 with 25 parameters
 Not all eigenvalues of the Hessian are positive: 615.016338157048, 483.081121414487, 459.314558037973, 399.471300017062, 339.000591494527, 269.79700376137, 250.768168847768, 173.592527069377, 168.848747746155, 127.031863709352, 113.476411053789, 83.229874604559, 77.8115444506399, 57.0222115582321, 33.1213063522529, 18.1405438539593, 17.5199831929771, 9.34753112744178, 2.93892935014479, 2.08944528819435, 0.00291331639207674, 0.00000002082995598457, -0.00000918497680505715, -0.00263784653169996, -2.66167808273334

Beginning fit attempt 10 of at maximum 10 extra tries
Running m1 with 25 parameters
 Not all eigenvalues of the Hessian are positive: 645.114711108459, 597.63688916834, 513.303483338091, 454.147231500585, 391.118735766138, 279.374701492399, 199.540173233592, 157.887173304268, 150.458697976877, 123.697250971411, 109.726723104449, 85.3725292736146, 76.4863195077474, 54.7949846111378, 30.03900307476, 17.5582957080828, 15.3932805380737, 8.99979782125786, 2.82719204249549, 2.06173948008854, 0.00324268481892292, 0.000000078646030850487, -0.000248582337960415, -0.00301583262296761, -2.36219924433445

Retry limit reached

 Retry limit reached; Best fit=929.73877 (started at 929.73877)  (11 attempt(s): 11 valid, 0 errors)
 Start values from best fit:
-0.188955204629201,-0.0147208115912736,0.152866539836663,-0.360053813351382,0.788816034315865,1.07073545281762,-0.364105741814631,1.13385602512168,0.812796569626933,0.115099761063936,1.01601745622033,0.0311536389942776,0.120157628130679,0.0203353477791497,0.868876014072572,1.3732046858793,-0.0113422819782369,0.048941744226473,0.0123558799829854,0.0654763892024481,0.001,0.001,-0.617445251967115,0.968430923280943,0.922667168374113
?umxSummary std=T|F', digits, report= 'html', filter= 'NS' & more
Running Saturated m1 with 21 parameters
Running Independence m1 with 11 parameters


Table: Parameter loadings for model 'm1'

|   |name                                               | Estimate|SE     |type          |
|:--|:--------------------------------------------------|--------:|:------|:-------------|
|7  |cd_estado_civil_with_cod_local_domic_fam_eq        |    -0.36|0.165  |Manifest Cov  |
|8  |age_cat_with_cd_estado_civil                       |     0.81|       |Manifest Cov  |
|9  |ah_paciente_sexo_with_cd_estado_civil              |     0.03|       |Manifest Cov  |
|11 |age_cat_with_cod_local_domic_fam_eq                |     0.12|       |Manifest Cov  |
|12 |ah_paciente_sexo_with_cod_local_domic_fam_eq       |     0.12|       |Manifest Cov  |
|14 |age_cat_with_ah_paciente_sexo                      |     0.02|       |Manifest Cov  |
|1  |cd_estado_civil_to_nhosp                           |    -0.19|0.712  |Manifest path |
|2  |cod_local_domic_fam_eq_to_nhosp                    |    -0.01|0.342  |Manifest path |
|3  |age_cat_to_nhosp                                   |     0.15|0.616  |Manifest path |
|4  |ah_paciente_sexo_to_nhosp                          |    -0.36|       |Manifest path |
|16 |one_to_nhosp                                       |     1.37|       |Mean          |
|17 |one_to_cd_estado_civil                             |    -0.01|0.204  |Mean          |
|18 |one_to_cod_local_domic_fam_eq                      |     0.05|14.485 |Mean          |
|19 |one_to_age_cat                                     |     0.01|0.174  |Mean          |
|20 |one_to_ah_paciente_sexo                            |     0.06|       |Mean          |
|5  |nhosp_with_nhosp                                   |     0.79|0.187  |Residual      |
|6  |cd_estado_civil_with_cd_estado_civil               |     1.07|0.327  |Residual      |
|10 |cod_local_domic_fam_eq_with_cod_local_domic_fam_eq |     1.13|0.902  |Residual      |
|13 |age_cat_with_age_cat                               |     1.02|0.258  |Residual      |
|15 |ah_paciente_sexo_with_ah_paciente_sexo             |     0.87|       |Residual      |

Model Fit: χ²(-4) = -0.15, p = NaN; CFI = 0.859; TLI = 1; RMSEA = 0
Algebra'threshMat':


|     | cd_estado_civil|cod_local_domic_fam_eq | age_cat| ah_paciente_sexo|
|:----|---------------:|:----------------------|-------:|----------------:|
|th_1 |            0.74|-0.62                  |   -1.50|             0.92|
|th_2 |            2.07|0                      |   -0.75|             0.92|
|th_3 |            2.07|0.01                   |    0.22|             0.92|
|th_4 |            2.07|0.01                   |    0.22|             0.93|
Running Saturated m1 with 21 parameters
Running Independence m1 with 11 parameters
umxConfint(model, parm= "all", run=TRUE)
Running m1 with 25 parameters
                                                   lbound estimate ubound
cd_estado_civil_to_nhosp                               NA   -0.189     NA
cod_local_domic_fam_eq_to_nhosp                        NA   -0.015     NA
age_cat_to_nhosp                                       NA    0.153     NA
ah_paciente_sexo_to_nhosp                              NA   -0.360     NA
nhosp_with_nhosp                                       NA    0.789     NA
cd_estado_civil_with_cd_estado_civil                   NA    1.071     NA
cd_estado_civil_with_cod_local_domic_fam_eq            NA   -0.364     NA
cod_local_domic_fam_eq_with_cod_local_domic_fam_eq     NA    1.134     NA
age_cat_with_cd_estado_civil                           NA    0.813     NA
age_cat_with_cod_local_domic_fam_eq                    NA    0.115     NA
age_cat_with_age_cat                                   NA    1.016     NA
ah_paciente_sexo_with_cd_estado_civil                  NA    0.031     NA
ah_paciente_sexo_with_cod_local_domic_fam_eq           NA    0.120    234
age_cat_with_ah_paciente_sexo                          NA    0.020     NA
ah_paciente_sexo_with_ah_paciente_sexo                 NA    0.869     NA
one_to_nhosp                                           NA    1.373     NA
one_to_cd_estado_civil                                 NA   -0.011     NA
one_to_cod_local_domic_fam_eq                          NA    0.049     NA
one_to_age_cat                                         NA    0.012     NA
one_to_ah_paciente_sexo                                NA    0.065     NA
cd_estado_civil_dev3                                   NA    0.001     NA
cd_estado_civil_dev4                                   NA    0.001     NA
cod_local_domic_fam_eq_dev1                            NA   -0.617     NA
age_cat_dev3                                           NA    0.968     NA
ah_paciente_sexo_dev1                                  NA    0.923     NA
                                                   lbound Code ubound Code
cd_estado_civil_to_nhosp                                    NA          NA
cod_local_domic_fam_eq_to_nhosp                             NA          NA
age_cat_to_nhosp                                            NA          NA
ah_paciente_sexo_to_nhosp                                   NA          NA
nhosp_with_nhosp                                            NA          NA
cd_estado_civil_with_cd_estado_civil                        NA          NA
cd_estado_civil_with_cod_local_domic_fam_eq                 NA          NA
cod_local_domic_fam_eq_with_cod_local_domic_fam_eq          NA          NA
age_cat_with_cd_estado_civil                                NA          NA
age_cat_with_cod_local_domic_fam_eq                         NA          NA
age_cat_with_age_cat                                        NA          NA
ah_paciente_sexo_with_cd_estado_civil                       NA          NA
ah_paciente_sexo_with_cod_local_domic_fam_eq                NA           3
age_cat_with_ah_paciente_sexo                               NA          NA
ah_paciente_sexo_with_ah_paciente_sexo                      NA          NA
one_to_nhosp                                                NA          NA
one_to_cd_estado_civil                                      NA          NA
one_to_cod_local_domic_fam_eq                               NA          NA
one_to_age_cat                                              NA          NA
one_to_ah_paciente_sexo                                     NA          NA
cd_estado_civil_dev3                                        NA          NA
cd_estado_civil_dev4                                        NA          NA
cod_local_domic_fam_eq_dev1                                 NA          NA
age_cat_dev3                                                NA          NA
ah_paciente_sexo_dev1                                       NA          NA
mxCheckIdentification(model)$status
Model is locally identified
[1] TRUE
plot(model)

?plot.MxModel options: std, means, digits, strip_zero, file, splines=T/F/ortho,..., min=, max =, same = , fixed, resid= 'circle|line|none'

System information

R version 4.1.2 (2021-11-01)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS Linux 8

Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblas-r0.3.12.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] parallel  splines   stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
 [1] umx_4.10.50            OpenMx_2.19.8          xtable_1.8-4          
 [4] gapminder_0.3.0        table1_1.4.2           scales_1.1.1          
 [7] ggthemes_4.2.4         gamlss_5.3-4           nlme_3.1-153          
[10] gamlss.dist_6.0-1      MASS_7.3-54            gamlss.data_6.0-2     
[13] GGally_2.1.2           lubridate_1.8.0        ggfortify_0.4.14      
[16] oddsratio_2.0.1        ggsci_2.9              ggplot2_3.3.5         
[19] margins_0.3.26         kableExtra_1.3.4       naniar_0.6.1          
[22] visdat_0.5.3           tableone_0.13.0        summarytools_1.0.0    
[25] janitor_2.1.0          stringr_1.4.0          gtsummary_1.5.0       
[28] skimr_2.1.3            plyr_1.8.6             dplyr_1.0.7           
[31] tidyr_1.1.4            magrittr_2.0.1         data.table_1.14.2     
[34] here_1.0.1             ProjectTemplate_0.10.2 tibble_3.1.6          
[37] digest_0.6.29         

loaded via a namespace (and not attached):
 [1] colorspace_2.0-2    pryr_0.1.5          ellipsis_0.3.2     
 [4] rprojroot_2.0.2     snakecase_0.11.0    base64enc_0.1-3    
 [7] rstudioapi_0.13     lavaan_0.6-9        farver_2.1.0       
[10] bit64_4.0.5         mvtnorm_1.1-3       fansi_0.5.0        
[13] xml2_1.3.3          codetools_0.2-18    mnormt_2.0.2       
[16] knitr_1.37          Formula_1.2-4       jsonlite_1.7.2     
[19] gt_0.3.1            DiagrammeR_1.0.6.1  compiler_4.1.2     
[22] httr_1.4.2          backports_1.4.1     assertthat_0.2.1   
[25] Matrix_1.3-4        fastmap_1.1.0       survey_4.1-1       
[28] cli_3.1.0           visNetwork_2.1.0    htmltools_0.5.2    
[31] tools_4.1.2         gtable_0.3.0        glue_1.6.0         
[34] rsvg_2.1.2          V8_4.0.0            Rcpp_1.0.7         
[37] jquerylib_0.1.4     vctrs_0.3.8         svglite_2.0.0      
[40] broom.helpers_1.5.0 DiagrammeRsvg_0.1   xfun_0.29          
[43] rvest_1.0.2         lifecycle_1.0.1     RColorBrewer_1.1-2 
[46] curl_4.3.2          yaml_2.2.1          gridExtra_2.3      
[49] MuMIn_1.43.17       pander_0.6.4        reshape_0.8.8      
[52] stringi_1.7.6       highr_0.9           checkmate_2.0.0    
[55] polycor_0.8-0       repr_1.1.4          rlang_0.4.12       
[58] pkgconfig_2.0.3     systemfonts_1.0.3   matrixStats_0.61.0 
[61] evaluate_0.14       lattice_0.20-45     purrr_0.3.4        
[64] prediction_0.3.14   labeling_0.4.2      rapportools_1.0    
[67] htmlwidgets_1.5.4   bit_4.0.4           cowplot_1.1.1      
[70] tidyselect_1.1.1    R6_2.5.1            magick_2.7.3       
[73] generics_0.1.1      DBI_1.1.2           pillar_1.6.4       
[76] withr_2.4.3         mgcv_1.8-38         survival_3.2-13    
[79] crayon_1.4.2        utf8_1.2.2          tmvnsim_1.0-2      
[82] rmarkdown_2.11      grid_4.1.2          pbivnorm_0.6.0     
[85] webshot_0.5.2       numDeriv_2016.8-1.1 stats4_4.1.2       
[88] RcppParallel_5.1.5  munsell_0.5.0       viridisLite_0.4.0  
[91] mitools_2.4         tcltk_4.1.2